#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  02-firewalld
# Version	:  1.0
# Date		:  2022/01/21
# Author	:  Lz
# Email		:  liuzuo@kylinos.com.cn 
# History	:     
# 	            Version 1.0, 2022/01/21
# Function	:   系统防火墙服务
# Out		:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

# 测试主题
Title_Env_LTFLIB="安全加固(网络类) - 系统防火墙服务"


## TODO : 个性化,初始化
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestInit_LTFLIB(){
	if [ "Z${FirewalldSvc_Network_SSRFlag}" == "Z" ];then
		OutputRet_LTFLIB "${ERROR}"	
		TestRetParse_LTFLIB "未定义变量 FirewalldSvc_Network_SSRFlag"
	elif [ "Z${FirewalldSvc_Network_SSRFlag}" != "ZTrue" -a "Z${FirewalldSvc_Network_SSRFlag}" != "ZFalse" ];then
		OutputRet_LTFLIB "${ERROR}"	
		TestRetParse_LTFLIB "FirewalldSvc_Network_SSRFlag 无效的参数: ${FirewalldSvc_Network_SSRFlag}"
	fi

        return $TPASS
}


## TODO : 清理函数
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestClean_LTFLIB(){
        return $TPASS
}


## TODO : 测试用例集
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
Testsuite_LTFLIB(){
        testcase_1
        return $TPASS
}


## TODO : 测试用例
testcase_1(){
	local svcname="firewalld"

	SvcEnable_LTFLIB "${FirewalldSvc_Network_SSRFlag}" "no" "${svcname}"
	TestRetParse_LTFLIB "$svcname 要求自启动状态为 ${FirewalldSvc_Network_SSRFlag}"

	SvcActive_LTFLIB "${FirewalldSvc_Network_SSRFlag}" "no" "${svcname}"
	TestRetParse_LTFLIB "$svcname 要求当前状态为 ${FirewalldSvc_Network_SSRFlag}"
}


#----------------------------------------------#

source "${LIB_LTFLIB}"
Main_LTFLIB $@
